package com.bupt.fmmall.controller;

import com.bupt.fmmall.entity.Customer;
import com.bupt.fmmall.entity.ShoppingCart;
import com.bupt.fmmall.service.CustomerService;
import com.bupt.fmmall.service.ShoppingCartService;
import com.bupt.fmmall.vo.ResultVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@ResponseBody
@RequestMapping("/submitorder")
@CrossOrigin
public class SubmitorderController {
    @Resource
    CustomerService customerService;
    @Resource
    ShoppingCartService shoppingCartService;

    @RequestMapping("/getinfo")
    public ResultVO getCustomerInfo(String customerUserName){
        return customerService.getCustomerInfoByUsername(customerUserName);
    }

    @RequestMapping("/getchooseitems")
    public ResultVO getCustomerChooseItems(String itemId,String customerUserName){
        return shoppingCartService.findChoosenCart(itemId,customerUserName);
    }

    @RequestMapping("changeinfo")
    public ResultVO changeCustomerInfo(Customer customer){
        return customerService.changeReceiptInfo(customer);
    }
}
